<template>
  <el-form label-width="100px">
    <el-form-item label="标签">
      <el-input v-model="props.label" />
    </el-form-item>
    <el-form-item label="占位文本">
      <el-input v-model="props.placeholder" />
    </el-form-item>
    <el-form-item label="选项">
      <div v-for="(option, index) in props.options" :key="index" class="mb-2">
        <div class="flex gap-2">
          <el-input v-model="option.label" placeholder="选项文本" />
          <el-input v-model="option.value" placeholder="选项值" />
          <el-button type="danger" @click="removeOption(index)">
            <Icon icon="ep:delete" />
          </el-button>
        </div>
      </div>
      <el-button type="primary" @click="addOption">
        <Icon icon="ep:plus" class="mr-2" />添加选项
      </el-button>
    </el-form-item>
    <el-form-item>
      <el-checkbox v-model="props.multiple">多选</el-checkbox>
      <el-checkbox v-model="props.required">必填</el-checkbox>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
const props = defineModel()

const addOption = () => {
  props.value.options.push({ label: '', value: '' })
}

const removeOption = (index: number) => {
  props.value.options.splice(index, 1)
}
</script> 